package com.dashuai.controller;

import com.dashuai.pojo.Order;
import com.dashuai.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/order")
public class OrderController {


    @Autowired
    private OrderService orderService;

    @GetMapping("/{id}")
    public Order fingById(@PathVariable("id") Long orderId) {
        Order order = orderService.findById(orderId);
        return order;
    }

    @GetMapping("/fingBySaveTimeCom/{saveTimeCom}")
    public Order fingBySaveTimeCom(@PathVariable("saveTimeCom") Long saveTimeCom) {
        Order order = orderService.findBySaveTimeCom(saveTimeCom);
        return order;
    }

    @GetMapping("/createTable")
    public String createTable() {
        try {
            orderService.createTable();
        } catch (Exception e) {
            e.printStackTrace();
            return "建表失败";
        }
        return "建表成功";
    }

}
